import pandas as pd

# 创建多个 DataFrame
data1 = {
    '姓名': ['张三', '李四', '王五'],
    '年龄': [25, 30, 35]
}
df1 = pd.DataFrame(data1)

data2 = {
    '城市': ['北京', '上海', '广州'],
    '省份': ['北京', '上海', '广东']
}
df2 = pd.DataFrame(data2)

output_doc = 'D:/opt/mul2.xlsx'
# 将多个 DataFrame 写入不同的工作表
with pd.ExcelWriter(output_doc) as writer:
    df1.to_excel(writer, sheet_name='Sheet1', index=False)
    df2.to_excel(writer, sheet_name='Sheet2', index=False)
